package com.shanzmoo.admin.web;

import com.shanzmoo.admin.domain.bo.MallOrderContactsBO;
import com.shanzmoo.admin.domain.bo.MallOrderInvoiceBO;
import com.shanzmoo.base.bean.PageRespBase;
import com.shanzmoo.base.bean.SHttpResponse;
import com.shanzmoo.base.bean.SResponse;
import com.shanzmoo.admin.manager.MallOrderManager;
import com.shanzmoo.db.mall.entity.bo.MallOrderAddLogisticsBO;
import com.shanzmoo.db.mall.entity.bo.MallOrderSellerRemarkBO;
import com.shanzmoo.db.mall.entity.query.MallOrderPageQuery;
import com.shanzmoo.db.mall.entity.vo.MallOrderPageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 商城-订单管理
 *
 * @author Gzhao 2021/1/6
 */
@Slf4j
@Api(tags = "商城-订单管理")
@RestController
@RequestMapping("/mall/order")
public class MallOrderController {

    @Autowired
    private MallOrderManager mallOrderManager;

    @ApiOperation(value = "分页列表")
    @PostMapping("/pageList")
    public SHttpResponse<PageRespBase<MallOrderPageVO>> pageList(@Valid @RequestBody MallOrderPageQuery query) {
        SResponse<PageRespBase<MallOrderPageVO>> re = mallOrderManager.getPageList(query);
        return SHttpResponse.transform(re);
    }

    @ApiOperation(value = "发货")
    @PostMapping("/addLogistics")
    public SHttpResponse<Boolean> addLogistics(@Valid @RequestBody MallOrderAddLogisticsBO logistics) {
        SResponse<Boolean> re = mallOrderManager.addLogistics(logistics);
        return SHttpResponse.transform(re);
    }

    @ApiOperation(value = "添加卖家备注")
    @PostMapping("/addSellerRemark")
    public SHttpResponse<Boolean> addSellerRemark(@Valid @RequestBody MallOrderSellerRemarkBO sellerRemark) {
        SResponse<Boolean> re = mallOrderManager.addSellerRemark(sellerRemark);
        return SHttpResponse.transform(re);
    }

    @ApiOperation(value = "修改联系人信息")
    @PostMapping("/updateContacts")
    public SHttpResponse<Boolean> updateContacts(@Valid @RequestBody MallOrderContactsBO request) {
        SResponse<Boolean> re = mallOrderManager.updateContacts(request);
        return SHttpResponse.transform(re);
    }

    @ApiOperation(value = "修改发票信息")
    @PostMapping("/updateInvoice")
    public SHttpResponse<Boolean> updateInvoice(@Valid @RequestBody MallOrderInvoiceBO request) {
        SResponse<Boolean> re = mallOrderManager.updateInvoice(request);
        return SHttpResponse.transform(re);
    }
}
